module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),



      csslint: {

       
        src: ['src/**/*.css']
        
      },
      jshint: {
          all: ['src/**/*.js']
        },
    transport: {

      options: {
        paths: ["."],
        alias: '<%= pkg.spm.alias %>',
        idleading: "http:/<%=pkg.family%>/<%=pkg.name%>/<%=pkg.version%>/",
        debug: true,
        handlebars: {
          id: 'handlebars'
        }
      },
      js: {
        // options: {
        //   idleading: 'http://cca.mbaobao.com/mkts/201512/10/xg/images/d/'

        // },
         options: {
                handlebars: {
                    id: 'gallery/handlebars/1.0.0/handlebars'
                }
            },
        files: [{
          // cwd: 'js/hellosea',//地址cwd+src
          // src: ['src/hellosea.js', 'src/util.js'],
          // dest: '.build',
          expand: true,
          cwd: 'src/',
          src: '**/*',
          filter: 'isFile',
          dest: 'dist/'
        }]
      },
      hbs: {
          options: {
              debug: false
          },
          files: [{
              expand:true,
              cwd: 'src/',
              src: '**/*.handlebars',
              filter: 'isFile',
              dest: 'dist/'
          }]
      }
    },
    concat: {
      hellosea: {
        options: {
          // 是否采用相对地址
          relative: true
        },
        files: {
          // 合并后的文件地址
          'dist/hellosea.js': ['dist/hellosea.js', 'dist/util.js']
        }
      }
    },
    uglify: {
      options: {
        banner: '/* <%= pkg.name %> by <%= pkg.author.name %> <%= grunt.template.today("yyyy-mm-dd hh:MM") %> */\n'
      },
      hellosea: {
        files: {
          'dist/hellosea.js': ['dist/hellosea.js'] //对dist/application.js进行压缩，之后存入dist/application.js文件

        }
      }

    },
    cssmin: {
      options: {
         banner: '/* <%= pkg.name %> by <%= pkg.author.name %> <%= grunt.template.today("yyyy-mm-dd hh:MM") %> */\n'
      },
      minify: {
        expand: true,
        cwd: 'src/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/',
        ext: '.css'
      }
    },
    'ftp-deploy': {
      release: {
        auth: {
          host: '10.7.7.11',
          port: "58421",
          authKey: 'ftp34'
        },
        src: 'dist/',
        dest: '<%=pkg.family%>/<%= pkg.name %>/<%= pkg.version %>/',
      }
    }
  });
  grunt.loadNpmTasks("grunt-contrib-csslint");
  grunt.loadNpmTasks("grunt-contrib-jshint");
  grunt.loadNpmTasks('grunt-cmd-transport');
  grunt.loadNpmTasks('grunt-cmd-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-ftp-deploy');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.registerTask("hbs", ["transport:hbs"]);
  // grunt.registerTask('default', ['transport','concat','uglify',"cssmin:minify",'ftp-deploy:release']);
  grunt.registerTask('default', ["csslint","jshint",'transport', 'concat', 'uglify', "cssmin:minify",'ftp-deploy:release']);



};